﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Text.LocationTagged`1
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using Microsoft.Internal.Web.Utils;
using System.Diagnostics;
using System.Globalization;

namespace System.Web.Razor.Text
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents a location tagged.</summary>
  /// <typeparam name="T">The type of the location tagged.</typeparam>
  [DebuggerDisplay("({Location})\"{Value}\"")]
  public class LocationTagged<T> : IFormattable
  {
    private LocationTagged()
    {
      this.Location = SourceLocation.Undefined;
      this.Value = default (T);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Text.LocationTagged`1" /> class.</summary>
    /// <param name="value">The value of the source.</param>
    /// <param name="offset">The offset.</param>
    /// <param name="line">The line.</param>
    /// <param name="col">The column location of the source.</param>
    public LocationTagged(T value, int offset, int line, int col)
      : this(value, new SourceLocation(offset, line, col))
    {
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Text.LocationTagged`1" /> class.</summary>
    /// <param name="value">The value of the source.</param>
    /// <param name="location">The location of the source.</param>
    public LocationTagged(T value, SourceLocation location)
    {
      if ((object) value == null)
        throw new ArgumentNullException(nameof (value));
      this.Location = location;
      this.Value = value;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the location of the source.</summary>
    /// <returns>The location of the source.</returns>
    public SourceLocation Location { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the value of the source.</summary>
    /// <returns>The value of the source.</returns>
    public T Value { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified object is equal to the current object.</summary>
    /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
    /// <param name="obj">The object to compare to.</param>
    public override bool Equals(object obj)
    {
      LocationTagged<T> locationTagged = obj as LocationTagged<T>;
      return locationTagged != (LocationTagged<T>) null && object.Equals((object) locationTagged.Location, (object) this.Location) && object.Equals((object) locationTagged.Value, (object) this.Value);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns the hash code for the current instance.</summary>
    /// <returns>The hash code for the current instance.</returns>
    public override int GetHashCode() => HashCodeCombiner.Start().Add((object) this.Location).Add((object) this.Value).CombinedHash;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns a string representation of the current instance.</summary>
    /// <returns>The string that represents the current instance.</returns>
    public override string ToString() => this.Value.ToString();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns a string representation of the current instance.</summary>
    /// <returns>A string that represents the current instance.</returns>
    /// <param name="format">The format.</param>
    /// <param name="formatProvider">The format provider.</param>
    public string ToString(string format, IFormatProvider formatProvider)
    {
      if (string.IsNullOrEmpty(format))
        format = "P";
      if (formatProvider == null)
        formatProvider = (IFormatProvider) CultureInfo.CurrentCulture;
      if (!(format.ToUpperInvariant() == "F"))
        return this.Value.ToString();
      return string.Format(formatProvider, "{0}@{1}", (object) this.Value, (object) this.Location);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Converts the specified value to a <see cref="T:System.Web.Razor.Text.LocationTagged`1" /> object.</summary>
    /// <returns>true if successfully converted; otherwise, false.</returns>
    /// <param name="value">The value to convert.</param>
    public static implicit operator T(LocationTagged<T> value) => value.Value;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the two <see cref="T:System.Web.Razor.Text.LocationTagged{`0}" /> object are equal.</summary>
    /// <returns>true if the two object are equal; otherwise, false.</returns>
    /// <param name="left">The first object to compare.</param>
    /// <param name="right">The second object to compare.</param>
    public static bool operator ==(LocationTagged<T> left, LocationTagged<T> right) => object.Equals((object) left, (object) right);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the two <see cref="T:System.Web.Razor.Text.LocationTagged{`0}" /> object are not equal.</summary>
    /// <returns>true if the two object are not equal; otherwise, false.</returns>
    /// <param name="left">The first object to compare.</param>
    /// <param name="right">The second objet to compare.</param>
    public static bool operator !=(LocationTagged<T> left, LocationTagged<T> right) => !object.Equals((object) left, (object) right);
  }
}
